package org.nfIt.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.nfIt.dto.product.CategoryBrandDto;
import org.nfIt.entity.product.Brand;
import org.nfIt.entity.product.CategoryBrand;
import org.nfIt.mapper.CategoryBrandMapper;
import org.nfIt.service.CategoryBrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * ClossName:CategoryBrandServiceImpl
 * Pakage:org.nfIt.service.impl
 * Description
 *
 * @Author L
 * @Create 2024/8/16 20:28
 * @Version 2023.1.3
 */
@Service
public class CategoryBrandServiceImpl implements CategoryBrandService {


    @Autowired
    private CategoryBrandMapper categoryBrandMapper;

    /**
     * 分类品牌条件查询
     * @param page 当前页
     * @param limit 每页记录数
     * @param categoryBrandDto 查询条件
     */
    @Override
    public PageInfo<CategoryBrand> findByPage(Integer page, Integer limit, CategoryBrandDto categoryBrandDto) {

        PageHelper.startPage(page,limit);
        List<CategoryBrand> list = categoryBrandMapper.findByPage(categoryBrandDto);
        PageInfo<CategoryBrand> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    /**
     * 添加品牌
     */
    @Override
    public void save(CategoryBrand categoryBrand) {
        categoryBrandMapper.save(categoryBrand);
    }

    //    根据分类id查询对应的品牌数据
    @Override
    public List<Brand> findBrandByCategoryId(Long categoryId) {
        return categoryBrandMapper.findBrandByCategoryId(categoryId);
    }
}
